home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 9
/
The PC-SIG Library on CD ROM - Ninth Edition.iso
/
701_800
/
DISK0778
/
DISK0778.ZIP
/
A85
/
LABGEN.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-05-10
|
2KB
|
58 lines
; Some useful macros to help get you started.
;
; Please note that all of the examples use 6800 instructions and thus
; will generate error messages when assembled on other assemblers. Just
; ignore those messages (or substitute the equivalent opcode for your
; processor)--the macro ideas depicted are still valid.
;
; Unique generated labels.
;
; Some macros will require "local" labels unique to a given expansion.
; The following macros are one way of creating them.
;
; nlabel creates a new unique identifier (of the form l1nnnn, where n varies)
; each invocation.
;
; nlabel returns the current value of glabel, and then redefines glabel to
; the value one greater than glabel.
;
define( glabel,10000)
define( nlabel,``l'glabel`'define(`glabel',iner(glabel))')
;
; Now we have a unique label generator, but each time we call it the label
; will be different, and thus of little use for branches and jumps.
;
; We must assign this unique label string to an identifier for multiple
; uses.
;
define(local1,nlabel)
local1: nop
jmp local1
jsr local1
undefine(`local1')
local1: nop
;
; Above we define local1 to be the string generated by nlabel, use that
; string in several places, and then undefine it. Note that local1 after
; the undefine is "local1" and not a generated string. If defined locals
; are not undefined when we are done with them, we would quickly run out
; of memory space (in the macro table).
;
define(loop, ` define(local1,nlabel)
local1: nop
jmp local1
undefine(`local1')')
loop
loop
loop
; Above the macro loop is genrated three times, each time with unique local
; labels as looping targets.